home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / WINSYS.PAK / EXBASE.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  2KB  |  74 lines

  1. //----------------------------------------------------------------------------
  2. // Borland WinSys Library
  3. // Copyright (c) 1994, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   5.6  $
  6. //
  7. //   Base exception support for framework exceptions
  8. //----------------------------------------------------------------------------
  9. #if !defined(WINSYS_EXBASE_H)
  10. #define WINSYS_EXBASE_H
  11.  
  12. #if !defined(WINSYS_DEFS_H)
  13. # include <winsys/defs.h>
  14. #endif
  15.  
  16. //----------------------------------------------------------------------------
  17. // Exception support comes in two levels.
  18. //
  19. //  1) No emulation provided, any compiler support disabled. Throwing causes
  20. //     an abort. (DISABLE_EXCEPTIONS defined)
  21. //
  22. //  2) Compiler support exceptions (DISABLE_EXCEPTIONS not defined)
  23. //
  24. // BI_NO_EXCEPTIONS comes from winsys/compiler.h
  25. // DISABLE_EXCEPTIONS comes from the outside
  26. //
  27. #if defined(DISABLE_EXCEPTIONS)  // (level 1 -- exceptions disabled)
  28. # define TRY
  29. # define CATCH(arg_and_code)
  30. # define ENDCATCH
  31. # define THROW(expr) abort()
  32. # define RETHROW
  33.  
  34. #else                            // (level 2 -- compiler support required)
  35. # include <services/except.h>
  36.  
  37. # define TRY try
  38. # define CATCH(arg_and_code)  catch arg_and_code
  39. # define ENDCATCH
  40. # define THROW(expr) throw expr
  41. # define RETHROW throw
  42. #endif
  43.  
  44. #if defined(BI_NAMESPACE)
  45. namespace ClassLib {
  46. #endif
  47.  
  48. //----------------------------------------------------------------------------
  49. //
  50. // Derived exception class that supports cloning, rethrowing & instance
  51. // counting
  52. //
  53.  
  54. class _WSYSCLASS_RTL TXBase : public xmsg {
  55.   public:
  56.     TXBase(const string& msg);
  57.     TXBase(const TXBase& src);
  58.     virtual ~TXBase();
  59.  
  60.     virtual TXBase* Clone();
  61.     virtual void Throw();
  62.  
  63.     static void Raise(const string& msg);
  64.  
  65.   //private:
  66.     static int InstanceCount;
  67. };
  68.  
  69. #if defined(BI_NAMESPACE)
  70. }     // namespace ClassLib
  71. #endif
  72.  
  73. #endif  // WINSYS_EXBASE_H
  74.